home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / doc / gpc / demos / filebuf1demo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-02-08  |  1.7 KB  |  51 lines

  1. {
  2. GPC demo program. Reverse the characters of a string read from the
  3. input. The point is not that it's possible at all, but that it's
  4. possible without having to declare *any* variable -- of course, this
  5. recursive way is not the most efficient solution, it's just a nice
  6. little thing one can do with file buffers. (File buffers are a
  7. Standard Pascal feature missing in many popular Pascal compilers.)
  8.  
  9. Copyright (C) 1999-2001 Free Software Foundation, Inc.
  10.  
  11. Author: Frank Heckenbach <frank@pascal.gnu.de>
  12.  
  13. This program is free software; you can redistribute it and/or
  14. modify it under the terms of the GNU General Public License as
  15. published by the Free Software Foundation, version 2.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program; see the file COPYING. If not, write to
  24. the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  25. Boston, MA 02111-1307, USA.
  26.  
  27. As a special exception, if you incorporate even large parts of the
  28. code of this demo program into another program with substantially
  29. different functionality, this does not cause the other program to
  30. be covered by the GNU General Public License. This exception does
  31. not however invalidate any other reasons why it might be covered
  32. by the GNU General Public License.
  33. }
  34.  
  35. program FileBufferDemo1;
  36.  
  37. procedure Reverse (ch : Char);
  38. begin
  39.   Get (Input);
  40.   if not EOLn then Reverse (Input^);
  41.   Write (ch)
  42. end;
  43.  
  44. begin
  45.   Write ('Enter a string: ');
  46.   while EOLn do Readln;
  47.   Write ('The reversed string is `');
  48.   Reverse (Input^);
  49.   Writeln ('''')
  50. end.
  51.